ls = [x * 10 for x in range(1, 11)]

# 遍历
for i in ls:
    print(i, end=" ")

print()

# 复制
ls2 = ls
print("【ls2 = ls】id of ls: {0}, id of ls2: {1}, ls2: {2}".format(id(ls), id(ls2), ls2))

ls3 = []
ls3.extend(ls)
print(
    "【ls3 = [].extend(ls)】id of ls: {0}, id of ls3: {1}, ls3: {2}".format(
        id(ls), id(ls3), ls3
    )
)

ls4 = [] + ls
print(
    "【ls4 = [] + ls】id of ls: {0}, id of ls4: {1}, ls4: {2}".format(
        id(ls), id(ls4), ls4
    )
)

# 原地排序，不生成新列表
ls.sort()
print("ls.sort(): ", ls)
ls.sort(reverse=True)
print("ls.sort(reverse=True): ", ls)

# 乱序
import random

random.shuffle(ls)
print("random.shuffle(ls): ", ls)

# 将排序结果生成新列表
ls5 = sorted(ls)
print("sorted(ls): {0}({1}), {2}({3})".format(ls, id(ls), ls5, id(ls5)))

ls6 = sorted(ls, reverse=True)
print("sorted(ls, reverse=True): {0}({1}), {2}({3})".format(ls, id(ls), ls6, id(ls6)))

ls7 = list(reversed(ls))
print("reversed(ls): {0}({1}), {2}({3})".format(ls, id(ls), ls7, id(ls7)))

# 最小/大值、求和
print("min(ls): ", min(ls), ", max(ls): ", max(ls), ", sum(ls): ", sum(ls))
